package com.example.demo.exception;


import com.example.demo.entity.Response;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.SignatureException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * token过期
     *
     * @return
     */
    @ExceptionHandler(value = ExpiredJwtException.class)
    @ResponseBody
    public Response expiredJwtException() {
        return Response.ok(999,"token expired");
    }


    /**
     * token错误
     *
     * @return
     */
    @ExceptionHandler(value = SignatureException.class)
    @ResponseBody
    public Response signatureException() {
        return Response.ok(999,"token wrong");
    }

}


